﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SampleVariableGridView.Models;
using SampleVariableGridView.Services;

namespace SampleVariableGridView.ViewModel
{
    public class MainViewModel
    {
        public System.Collections.ObjectModel.ObservableCollection<Models.Flickr> Photos { get; set; }

        private Services.ServiceRss _serviceRss;
        private Microsoft.Practices.Prism.PubSubEvents.IEventAggregator _eventAggregator;
        
        public MainViewModel()
        {
            Photos = new ObservableCollection<Flickr>();
            _serviceRss = new ServiceRss();
            _eventAggregator = App.EventAggregator;
            _eventAggregator.GetEvent<Events.EventFlickr>().Subscribe(Recived);
        }

        public void LaodListPhotos()
        {
            _serviceRss.LoadListPhoto();
        }

        private void Recived(Models.Flickr input)
        {
            Photos.Add(input);
        }
    }
}
